package cn.funeralobjects.aoss.enums;

import lombok.Getter;

/**
 * @author FuneralObjects
 * Create date: 2020/6/8 9:20 AM
 */
public enum BucketAction {
    /**
     * 上传对象
     */
    PUT_OBJECT("oss:PutObject", (short) 1),

    /**
     * 下载对象
     */
    GET_OBJECT("oss:GetObject", (short) 2),

    /**
     * 更新对象
     */
    UPDATE_OBJECT("oss:UpdateObject", (short) 3);;
    /**
     * 编号
     */
    @Getter
    private final Short num;

    /**
     * 值
     */
    @Getter
    private final String action;

    BucketAction(String action, Short num) {
        this.num = num;
        this.action = action;
    }

    public static BucketAction of(Number num) {
        if (num == null) {
            return null;
        }
        for (BucketAction action : BucketAction.values()) {
            if (action.num.equals(num.shortValue())) {
                return action;
            }
        }
        return null;
    }

}
